package com.utils;

import java.util.List;

public class PageTools {
    private int currentpage;//当前页
    private int pagesize;//每页显示的条数
    private int sumsize;//总条数

    private int index;
    private int prepage;
    private int nextpage;
    private int sumpage;

    //存学生信息
    private List studentlist;

    public List getStudentlist() {
        return studentlist;
    }

    public void setStudentlist(List studentlist) {
        this.studentlist = studentlist;
    }

    //    public static void main(String[] args) {
//        PageTools p = new PageTools(2, 3, 33);
//        System.out.println(p);
//    }
    public PageTools(int currentpage, int pagesize, int sumsize) {
        this.currentpage = currentpage;
        this.pagesize = pagesize;
        this.sumsize = sumsize;

        index = (currentpage-1)*pagesize;
        prepage= currentpage==1?currentpage:currentpage-1;
        sumpage=sumsize/pagesize+(sumpage%sumsize==0?0:1);
        nextpage=currentpage==sumpage?currentpage:currentpage+1;
    }

    public int getCurrentpage() {
        return currentpage;
    }

    public void setCurrentpage(int currentpage) {
        this.currentpage = currentpage;
    }

    public int getPagesize() {
        return pagesize;
    }

    public void setPagesize(int pagesize) {
        this.pagesize = pagesize;
    }

    public int getSumsize() {
        return sumsize;
    }

    public void setSumsize(int sumsize) {
        this.sumsize = sumsize;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public int getPrepage() {
        return prepage;
    }

    public void setPrepage(int prepage) {
        this.prepage = prepage;
    }

    public int getNextpage() {
        return nextpage;
    }

    public void setNextpage(int nextpage) {
        this.nextpage = nextpage;
    }

    public int getSumpage() {
        return sumpage;
    }

    public void setSumpage(int sumpage) {
        this.sumpage = sumpage;
    }

    @Override
    public String toString() {
        return "PageTools{" +
                "currentpage=" + currentpage +
                ", pagesize=" + pagesize +
                ", sumsize=" + sumsize +
                ", index=" + index +
                ", prepage=" + prepage +
                ", nextpage=" + nextpage +
                ", sumpage=" + sumpage +
                ", studentlist=" + studentlist +
                '}';
    }
}
